// app.js
// 导入混入模块
// require('./mixins/index')
const {request ,loginApi} = require('./utils/api.js');
import Toast from '@vant/weapp/toast/toast';
App({
  globalData: {
    activeId:null
  },
    onLaunch() {
        console.log(request)
        const primaryColor = wx.getStorageSync('primaryColor')
        if (!primaryColor) {
            wx.setStorageSync('primaryColor', '#C8102E')
        }
        loginApi.wxMiniAppLogin()
        let _self = this;
        wx.getSystemInfo({
          success: res => {
            let modelmes = res.model;
            if (modelmes.search('iPhone X') != -1) {
              _self.globalData.isIphoneX = true
            }
            wx.setStorageSync('modelmes', modelmes)
            //导航高度
            this.globalData.navHeight = res.statusBarHeight + 46;
          }
        })
    },
    globalData: {
        // 存储自定义tabbar
        list: [],
        loginInfo: {},
        navHeight:0,
        isIphoneX:false,
        vrList:[],
        caseContent:'',
        selectLocate:null,
        pindex:-1,
        cindex:-1,
    },
    checkLogin() {
        if(!wx.getStorageSync('user') ||
         !wx.getStorageSync('user').member_id ||
           !wx.getStorageSync('user').member.phone
           ){
            wx.navigateTo({
                url: '/pages/grant/grant',
            })
            return false
        }
        return true
      },
})

// 全局页面分享
;(function () {
    //获取页面配置并进行页面分享配置
    var PageTmp = Page
    Page = function (pageConfig) {
        //1. 获取当前页面路由
        let routerUrl = ''
        wx.onAppRoute(function (res) {
            let pages = getCurrentPages(),
                view = pages[pages.length - 1]
            routerUrl = view.route
        })
        //2. 全局开启分享配置
        pageConfig = Object.assign(
            {
                // onShareAppMessage: function () {
                //     return {
                //         path: routerUrl,
                //     };
                // },
            },
            pageConfig
        )
        // 配置页面模板
        PageTmp(pageConfig)
    }
})()
